// tmpList/index.js
var imgUrls = require('../../utils/data.js').tmpImgUrls

//获取应用实例
const app = getApp()

Page({
  data: {
    // 全局 图片前缀
    prefix: app.globalData.oldPrefix ,
    logs: [],
    // swipe
    imgUrls: []
  },
  onShow: function () {
    this.setData({
      imgUrls: imgUrls
    })
  },
  
  selectTmpToMake(res){
    var index = res.currentTarget.dataset.itemIndex
    console.log(index)
    wx.navigateTo({
      url: '/pages/create-old/index?from=tmp&itemIndex=' + index ,
      success: function () {
        console.log('turn to create')
      }
    })
  },
  makeFromPhoto(){
    var that = this 
    wx.chooseImage({
      count: 1 ,
      sizeType: 'original',
      success :function(res){
        var tempFilePaths = res.tempFilePaths
        console.log(tempFilePaths, res.tempFiles )
        // 缓存中set下链接url
        wx.setStorage({
          key:'photoFile' ,
          data: tempFilePaths[0] ,
          success:function(){
            wx.navigateTo({
              url: '/pages/create-old/index?from=photo',
              success: function () {
                console.log('turn to create')
              }
            })
          }
        })
      },
      fail: function(){

      },
      complete :function(){

      }     

    })
  }
})
